//
// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-05-03  Jed Young  Creation
//

using concurrent
using fwt
using gfx
using gfx2
using gfx2Imp

using chunmapDesktop
using chunmapModel
using chunmapUtil
using chunmapView
using chunmapRaster

const class Main
{
  const Str handle := Uuid().toStr

  Void main()
  {
    Layer? layer
    map := MapCanvas
    {
      //layer = WmsLayer.makeUri(`http://localhost:8080/chunmapService/test?`)|->|
      //layer = GLayer.makeUri(`http://localhost:8080/chunmapService/test?`)|->|
      //layer = GLayer.makeUri(`http://mt2.google.cn/vt/v=w2.116&hl=zh-CN&gl=cn`)|->|
      layer = TileLayer.makeUri(`http://localhost:9080/chunmapService/test`)|->|
      {
        Desktop.callAsync |->| { Actor.locals[handle]->renderMap; echo(".") }
      }
      layers.add(layer)
      fullView
    }
    Actor.locals[handle] = map

    Window
    {
      title = "chunmap"
      size = Size(900,600)
      EdgePane
      {
        center = InsetPane { size = Size(900,500); content = map }
        bottom = Button{ text = "reset"; onAction.add { map.fullView.renderMap }}
      },
    }.open
  }
}